﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data;


namespace EzyChoice
{
    [Serializable()]
    public class EzcChoiceController : ISerializable
    {
        public Goal Goal = new Goal();
        public List<Alternative> Alternatives = new List<Alternative>();
        public List<Participate> Participates = new List<Participate>();

        //public DataTable WeightTable = new DataTable();
        //public DataTable ScoreTable = new DataTable();
        
        public EzcChoiceController()
        {
            //WeightTable.Columns.Add(new DataColumn("parti", typeof(string)));
            //WeightTable.Columns.Add(new DataColumn("item", typeof(string)));
            //WeightTable.Columns.Add(new DataColumn("weight", typeof(double)));
            //WeightTable.PrimaryKey = new DataColumn[] { WeightTable.Columns[0], WeightTable.Columns[1] };

            //ScoreTable.Columns.Add(new DataColumn("parti", typeof(string)));
            //ScoreTable.Columns.Add(new DataColumn("alter", typeof(string)));
            //ScoreTable.Columns.Add(new DataColumn("item", typeof(string)));
            //ScoreTable.Columns.Add(new DataColumn("rating", typeof(double)));
            //ScoreTable.PrimaryKey = new DataColumn[] { ScoreTable.Columns[0], ScoreTable.Columns[1], ScoreTable.Columns[2] };
            
        }

        protected EzcChoiceController(SerializationInfo info, StreamingContext context)
        {
            this.Goal = (Goal)info.GetValue("goal", typeof(Goal));
            this.Alternatives = (List<Alternative>)info.GetValue("alternatives", typeof(List<Alternative>));
            this.Participates = (List<Participate>)info.GetValue("participates", typeof(List<Participate>));
            //this.WeightTable = (DataTable)info.GetValue("weighttable", typeof(DataTable));
            //this.ScoreTable = (DataTable)info.GetValue("scoretable", typeof(DataTable));
        }



        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("goal", this.Goal);
            info.AddValue("alternatives", this.Alternatives);
            info.AddValue("participates", this.Participates);
            //info.AddValue("weighttable", this.WeightTable);
            //info.AddValue("scoretable", this.ScoreTable);
        }
    }
}
